package com.dhecp.project.system.controller;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dhecp.common.annotation.RepeatSubmit;
import com.dhecp.common.core.controller.BaseController;
import com.dhecp.common.core.domain.AjaxResult;
import com.dhecp.common.core.page.TableDataInfo;
import com.dhecp.common.utils.RandomValueUtils;
import com.dhecp.core.constant.ModuleTable;
import com.dhecp.core.layui.TreeDataModel;
import com.dhecp.core.layui.TreeDataUtil;
import com.dhecp.framework.util.ShiroUtils;
import com.dhecp.project.system.domain.MailContent;
import com.dhecp.project.system.service.MailContentService;

/**
 * 邮件系统 控制层
 * @author DH-Xxj
 * @version 2020年12月19日
 */
@Controller
@RequestMapping("/system/mail")
public class MailContentController extends BaseController {
	
    private String outboxTable = ModuleTable.MAIN_CONTENT;			//发件箱
    private String draftboxTable = ModuleTable.MAIN_CONTENT_DRAFT;	//草稿箱
    private String canceledTable = ModuleTable.MAIN_CONTENT_DRAFT;	//已撤销
    private String inboxTable = ModuleTable.RECIPIENT;				//收件箱
    private String deletedTable = ModuleTable.VMAIL_DELETED;		//已删除
    private String perpetualTable = ModuleTable.VMAIL_PERPETUAL;	//保留邮件
    
    @Autowired
    private MailContentService mailContentService;

    @Autowired
    private TreeDataUtil treeDataUtil;

    /**
     *	打开邮件系统新增、编辑、查看页面
     *	@param guid 行唯一值guid，新增可省略
     *	@param mailType 邮件状态（已收件、已发送、草稿、撤销），新增可省略
     *	@param fromPageType 列表页面类型：收件箱（inbox）、发件箱（outbox）、草稿箱（draftbox）、已撤消（canceled）、已删除（deleted）、保留邮件（perpetual）
     *	@param pageType 页面类型：新增（add）、编辑（edit）、回复（reply）、转发（transport）、查看（readonly）
     *	新增（add）：可编辑页面，所有内容为空
     *	编辑（edit）：可编辑页面，带出当前邮件所有内容，包括隐藏和显示的内容，适用于打开草稿进行编辑
     *	回复（reply）：可编辑页面，带出当前邮件所有内容，包括隐藏和显示的内容；原发件人变为收件人，抄送\密送为空（可重新选择），mailGuid赋值给pGuid
     *	转发（transport）：可编辑页面，带出当前邮件所有内容，包括隐藏和显示的内容；收件人\抄送\密送为空（可重新选择），mailGuid赋值给pGuid
     *	查看（readonly）：不可编辑页面，带出当前邮件所有内容，包括隐藏和显示的内容
     * @return
     * @author DH-Xxj
     */
    @GetMapping("/edit")
    @ResponseBody
    public Map<String, Object> mailContentEdit(@RequestParam Map<String, Object> params){
    	Map<String, Object> mv = new HashMap<String, Object>();
        String pageType = "readonly";
        String fromPageType = params.get("fromPageType").toString().toLowerCase();
        String mailType = "";
        if (params.get("pageType") != null && params.get("pageType") != ""){
        	pageType = params.get("pageType").toString().toLowerCase();
        }
        if (params.get("mailType") != null && params.get("mailType") != ""){
        	mailType = params.get("mailType").toString();
        }
        MailContent mailContent = new MailContent();
        if ("add".equals(pageType)){
        	mailContent.setFileMark(RandomValueUtils.getGUID());//附件关联字段，用于新增邮件时关联附件
            mailContent.setFromCid(ShiroUtils.getUserCid());
            mailContent.setFromCidName(ShiroUtils.getUserCidName());
            mailContent.setFromDept(ShiroUtils.getUserDeptPath());
            mailContent.setFromDeptName(ShiroUtils.getUserDeptName());
            mailContent.setFromUser(ShiroUtils.getUserId());
            mailContent.setFromUserName(ShiroUtils.getUserName());
        }else{
            if ("已收件".equals(mailType)){
            	mailContent = mailContentService.selectMailContentByGuid(params);
            }else{
            	mailContent = mailContentService.selectMainContentByGuid(params);
            }
            
        	if ("reply".equals(pageType)){
        		mailContent.setReplyGuid(mailContent.getGuid());
            	mailContent.setpGuid(mailContent.getMailGuid());	//mailGuid赋值给pGuid
        		
                mailContent.setToUser("[user]" + mailContent.getFromUser());
                mailContent.setToUserName(mailContent.getFromUserName());
                mailContent.setCcUser("");
                mailContent.setCcUserName("");
                mailContent.setScUser("");
                mailContent.setScUserName("");
                
                mailContent.setFromCid(ShiroUtils.getUserCid());
                mailContent.setFromCidName(ShiroUtils.getUserCidName());
                mailContent.setFromDept(ShiroUtils.getUserDeptPath());
                mailContent.setFromDeptName(ShiroUtils.getUserDeptName());
                mailContent.setFromUser(ShiroUtils.getUserId());
                mailContent.setFromUserName(ShiroUtils.getUserName());
        	}
        	if ("transport".equals(pageType)){
        		mailContent.setReplyGuid("transport");
            	mailContent.setpGuid(mailContent.getMailGuid());	//mailGuid赋值给pGuid
        		
                mailContent.setToUser("");
                mailContent.setToUserName("");
                mailContent.setCcUser("");
                mailContent.setCcUserName("");
                mailContent.setScUser("");
                mailContent.setScUserName("");
                
                mailContent.setFromCid(ShiroUtils.getUserCid());
                mailContent.setFromCidName(ShiroUtils.getUserCidName());
                mailContent.setFromDept(ShiroUtils.getUserDeptPath());
                mailContent.setFromDeptName(ShiroUtils.getUserDeptName());
                mailContent.setFromUser(ShiroUtils.getUserId());
                mailContent.setFromUserName(ShiroUtils.getUserName());
        	}
        }
        String moduleTable = "";
        if(fromPageType.equals("outbox")){ //发件箱
            moduleTable = outboxTable;
        }else if(fromPageType.equals("draftbox")){ //草稿箱
            moduleTable = draftboxTable;
        }else if(fromPageType.equals("canceled")){ //已撤销
            moduleTable = canceledTable;
        }else if(fromPageType.equals("inbox")){ //收件箱
            moduleTable = inboxTable;
        }else if(fromPageType.equals("deleted")){ //已删除
            moduleTable = deletedTable;
        }else if(fromPageType.equals("perpetual")){ //保留邮件
            moduleTable = perpetualTable;
        }
        mv.put("moduleTable", moduleTable); 	//邮件发件信息moduleTable
        mv.put("fromPageType", fromPageType); //列表页面类型：收件箱（inbox）、发件箱（outbox）、草稿箱（draftbox）、已撤消（canceled）、已删除（deleted）、保留邮件（perpetual）
        mv.put("pageType", pageType); 		//页面类型：新增（add）、编辑（edit）、回复（reply）、转发（transport）、查看（readonly）
        mv.put("mailContent", mailContent);	//邮件内容
        mv.put("mailDelDays", ShiroUtils.getSystemSet().getMailDelDays());	//非保留邮件保留天数（超期转已删除）
        return mv;
    }

    /**
     * 获取单条邮件记录
     * @param params
     * @return
     */
    @RequestMapping("/listById")
    @ResponseBody
    public AjaxResult listById(@RequestParam Map<String, Object> params){
        if (params.get("guid") == null || params.get("guid") == ""){
            return AjaxResult.error("请提供必要参数：guid。");
        }
        if (params.get("pageType") == null || params.get("pageType") == ""){
            return AjaxResult.error("请提供必要参数：pageType。");
        }
        AjaxResult ajaxResult = new AjaxResult();
        String pageType = "inbox";
        if (params.get("pageType") != null && params.get("pageType") != ""){
            pageType = params.get("pageType").toString().toLowerCase();
        }
        try{
            MailContent mailInfo = null;
            if ("inbox".equals(pageType)){
                mailInfo = mailContentService.selectMailContentByGuid(params);
            }else {
                mailInfo = mailContentService.selectMainContentByGuid(params);
            }
            if (mailInfo == null){
                ajaxResult =  AjaxResult.error("没有符合条件的数据。");
            }else{
                ajaxResult = AjaxResult.success("查询成功。", mailInfo);
            }
        }catch(Exception e){
            ajaxResult =  AjaxResult.error(this.getExceptionMessage(e));
        }
        return ajaxResult;
    }

    /**
     * 查询未读通知数
     * @param params
     * @return
     * @author DH-Xxj
     */
    @GetMapping("/listwds")
    @ResponseBody
    public TableDataInfo listWds(@RequestParam Map<String, Object> params) {
        Integer mailWdCount = 0;	//当前用户未读邮件数
        Integer mailCgCount = 0;	//当前用户草稿邮件数
        List<Map<String, Object>> mailWdCountList =  new ArrayList<Map<String, Object>>();
        try {
            mailWdCount = mailContentService.queryModuleMailWds(params);
            mailCgCount = mailContentService.queryModuleMailCgs(params);
            Map<String, Object> mailWdCountMap = new HashMap<String, Object>();
            mailWdCountMap.put("mailWdCount", mailWdCount);
            mailWdCountMap.put("mailCgCount", mailCgCount);
            mailWdCountList.add(mailWdCountMap);
        } catch (Exception e) {
            e.printStackTrace();
            return getDataTable(this.getExceptionMessage(e).toString());
        }
        return getDataTable(mailWdCountList);
    }
    
    /**
     * 查询邮件列表【收件箱、发件箱、草稿箱、已撤消、已删除】
     * @param pageType 页面类型：收件箱（inbox）、发件箱（outbox）、草稿箱（draftbox）、已撤消（canceled）、已删除（deleted）、保留邮件（perpetual）
     * @return
     * @author DH-Xxj
     */
    @GetMapping("/list")
    @ResponseBody
    public TableDataInfo list(@RequestParam Map<String, Object> params){
        List<MailContent> list = new ArrayList<MailContent>();
        try {
        	if (params.get("pageType") == null){
        		return getDataTable("页面类型【pageType】不能为空，可选值【收件箱（inbox）、发件箱（outbox）、草稿箱（draftbox）、已撤消（canceled）、已删除（deleted）、保留邮件（perpetual）】。");
        	}else if ("inbox".equals(params.get("pageType").toString().toLowerCase())){
        		//收件箱
            	params.put("moduleTable", inboxTable);
            	params.put("deleted", 0);
            	params.put("deletedSup", 0);
            	params.put("recUser", ShiroUtils.getUserId());
            	list = mailContentService.selectMailContentList(params);
        	}else if ("outbox".equals(params.get("pageType").toString().toLowerCase())){
        		//发件箱
            	params.put("moduleTable", outboxTable);
            	params.put("mailType", "已发送");
            	params.put("deleted", 0);
            	params.put("deletedSup", 0);
            	params.put("fromUser", ShiroUtils.getUserId());
            	list = mailContentService.selectMainContentList(params);
        	}else if ("draftbox".equals(params.get("pageType").toString().toLowerCase())){
        		//草稿箱
            	params.put("moduleTable", draftboxTable);
            	params.put("mailType", "草稿");
            	params.put("deleted", 0);
            	params.put("deletedSup", 0);
            	params.put("fromUser", ShiroUtils.getUserId());
            	list = mailContentService.selectMainContentList(params);
        	}else if ("canceled".equals(params.get("pageType").toString().toLowerCase())){
        		//已撤消
            	params.put("moduleTable", canceledTable);
            	params.put("mailType", "撤销");
            	params.put("deleted", 0);
            	params.put("deletedSup", 0);
            	params.put("fromUser", ShiroUtils.getUserId());
            	list = mailContentService.selectMainContentList(params);
        	}else if ("deleted".equals(params.get("pageType").toString().toLowerCase())){
        		//已删除
            	params.put("moduleTable", deletedTable);
            	params.put("recUser", ShiroUtils.getUserId());
            	list = mailContentService.selectDeletedMailList(params);
        	}else if ("perpetual".equals(params.get("pageType").toString().toLowerCase())){
        		//保留邮件
            	params.put("moduleTable", perpetualTable);
            	params.put("recUser", ShiroUtils.getUserId());
            	list = mailContentService.selectPerpetualMailList(params);
        	}else{
        		return getDataTable("页面类型【pageType】无效，可选值【收件箱（inbox）、发件箱（outbox）、草稿箱（draftbox）、已撤消（canceled）、已删除（deleted）、保留邮件（perpetual）】。");
        	}
        } catch (Exception e) {
            return getDataTable(this.getExceptionMessage(e).toString());
        }
        return getDataTable(list);
    }

    /**
     * 查询已选中的邮件标签
     * @param mailLabel ：已选中的邮件标签字符串，示例：公司;部门;个人;
     * @return TableDataInfo
     * @author DH-Xxj
     */
    @GetMapping("/maillabelselect")
    @ResponseBody
    public TableDataInfo mailLabelSelect(@RequestParam Map<String, Object> params){
    	if (params.get("mailLabel") != null && params.get("mailLabel") != ""){
    		String mailLabel = params.get("mailLabel").toString();
    		List<String> list = Arrays.asList(mailLabel.split(";"));
    		return getDataTable(list);
    	}else{
    		return getDataTable("请传入已选中的邮件标签字符串（mailLabel），取值示例：公司;部门;个人;");
    	}
    }

    /**
     * 保存草稿
     * @param infoItems 必要参数：邮件主表对应实体类的json格式字符串
     * 	guid、pGuid、主题、正文、收件人类型编码、收件人、抄送类型编码、抄送、密送类型编码、密送、附件关联、邮件标签、重要邮件、删除标记、彻底删除标记
     * @return AjaxResult
     * @author DH-Xxj
     */
    @PostMapping("/savepost")
    @ResponseBody
    @RepeatSubmit
    public AjaxResult mainContentSavePost(@RequestParam Map<String, Object> params) {
        AjaxResult ajaxResult = new AjaxResult();
        if (params.get("infoItems") == null || params.get("infoItems") == ""){
        	return AjaxResult.error("缺少参数infoItems【对应实体类的json格式字符串】。");
        }
        try {
        	params.put("mailType", "草稿");
        	ajaxResult= mailContentService.insertMainContent(params);
        }catch (Exception e) {
            ajaxResult = AjaxResult.error(this.getExceptionMessage(e));
        }
        return ajaxResult;
    }

    /**
     * 发送邮件
     * @param infoItems 必要参数：邮件主表对应实体类的json格式字符串
     * 	guid、pGuid、主题、正文、收件人类型编码、收件人、抄送类型编码、抄送、密送类型编码、密送、附件关联、邮件标签、重要邮件、删除标记、彻底删除标记
     * @return AjaxResult
     * @author DH-Xxj
     */
    @PostMapping("/sendpost")
    @ResponseBody
    @RepeatSubmit
    public AjaxResult mainContentSendPost(@RequestParam Map<String, Object> params) {
        AjaxResult ajaxResult = new AjaxResult();
        if (params.get("infoItems") == null || params.get("infoItems") == ""){
        	return AjaxResult.error("缺少参数infoItems【对应实体类的json格式字符串】。");
        }
        try {
        	params.put("mailType", "已发送");
        	ajaxResult= mailContentService.insertMainContent(params);
        }catch (Exception e) {
            ajaxResult = AjaxResult.error(this.getExceptionMessage(e));
        }
        return ajaxResult;
    }

    /**
     * 修改邮件状态（已发送、草稿、撤销），只改状态 不改其它内容
     * @param infoItems 必要参数：邮件主表对应实体类的json格式字符串（包含：guid，mailType 邮件状态（已发送、草稿、撤销））
     * @return AjaxResult
     * @author DH-Xxj
     */
    @PostMapping("/mailtypepost")
    @ResponseBody
    @RepeatSubmit
    public AjaxResult updateMailTypePost(@RequestParam Map<String, Object> params) {
        AjaxResult ajaxResult = new AjaxResult();
        if (params.get("infoItems") == null || params.get("infoItems") == ""){
        	return AjaxResult.error("缺少参数infoItems【对应实体类的json格式字符串】。");
        }
        try {
        	ajaxResult= mailContentService.updateMailType(params);
        }catch (Exception e) {
            ajaxResult = AjaxResult.error(this.getExceptionMessage(e));
        }
        return ajaxResult;
    }

    /**
     * 修改收件箱邮件已读标记
     * @param infoItems 必要参数：邮件主表对应实体类的json格式字符串（包含：guid，readed 已读标记）
     * @return AjaxResult
     * @author DH-Xxj
     */
    @PostMapping("/readedpost")
    @ResponseBody
    @RepeatSubmit
    public AjaxResult updateReadedPost(@RequestParam Map<String, Object> params) {
        AjaxResult ajaxResult = new AjaxResult();
        if (params.get("infoItems") == null || params.get("infoItems") == ""){
        	return AjaxResult.error("缺少参数infoItems【对应实体类的json格式字符串】。");
        }
        try {
        	ajaxResult= mailContentService.updateReaded(params);
        }catch (Exception e) {
            ajaxResult = AjaxResult.error(this.getExceptionMessage(e));
        }
        return ajaxResult;
    }

    /**
     * 修改邮件删除标记
     * @param infoItems 必要参数：邮件主表对应实体类的json格式字符串（包含：guid，deleted 删除标记，mailType 邮件状态（已收件、已发送、草稿、撤销））
     * @return AjaxResult
     * @author DH-Xxj
     */
    @PostMapping("/deletedpost")
    @ResponseBody
    @RepeatSubmit
    public AjaxResult updateDeletedPost(@RequestParam Map<String, Object> params) {
        AjaxResult ajaxResult = new AjaxResult();
        if (params.get("infoItems") == null || params.get("infoItems") == ""){
        	return AjaxResult.error("缺少参数infoItems【对应实体类的json格式字符串】。");
        }
        try {
        	ajaxResult= mailContentService.updateDeleted(params);
        }catch (Exception e) {
            ajaxResult = AjaxResult.error(this.getExceptionMessage(e));
        }
        return ajaxResult;
    }

    /**
     * 修改邮件彻底删除标记
     * @param infoItems 必要参数：邮件主表对应实体类的json格式字符串（包含：guid，deletedSup 彻底删除标记，mailType 邮件状态（已收件、已发送、草稿、撤销））
     * @return AjaxResult
     * @author DH-Xxj
     */
    @PostMapping("/deletedsuppost")
    @ResponseBody
    @RepeatSubmit
    public AjaxResult updateDeletedSupPost(@RequestParam Map<String, Object> params) {
        AjaxResult ajaxResult = new AjaxResult();
        if (params.get("infoItems") == null || params.get("infoItems") == ""){
        	return AjaxResult.error("缺少参数infoItems【对应实体类的json格式字符串】。");
        }
        try {
        	ajaxResult= mailContentService.updateDeletedSup(params);
        }catch (Exception e) {
            ajaxResult = AjaxResult.error(this.getExceptionMessage(e));
        }
        return ajaxResult;
    }

    /**
     * 修改邮件标签
     * @param infoItems 必要参数：邮件主表对应实体类的json格式字符串（包含：guid，mailLabel 邮件标签，mailType 邮件状态（已收件、已发送、草稿、撤销））
     * @return AjaxResult
     * @author DH-Xxj
     */
    @PostMapping("/maillabelpost")
    @ResponseBody
    @RepeatSubmit
    public AjaxResult updateMailLabelPost(@RequestParam Map<String, Object> params) {
        AjaxResult ajaxResult = new AjaxResult();
        if (params.get("infoItems") == null || params.get("infoItems") == ""){
        	return AjaxResult.error("缺少参数infoItems【对应实体类的json格式字符串】。");
        }
        try {
        	ajaxResult= mailContentService.updateMailLabel(params);
        }catch (Exception e) {
            ajaxResult = AjaxResult.error(this.getExceptionMessage(e));
        }
        return ajaxResult;
    }

    /**
     * 修改重要邮件标记
     * @param infoItems 必要参数：邮件主表对应实体类的json格式字符串（包含：guid，important 重要邮件，mailType 邮件状态（已收件、已发送、草稿、撤销））
     * @return AjaxResult
     * @author DH-Xxj
     */
    @PostMapping("/importantpost")
    @ResponseBody
    @RepeatSubmit
    public AjaxResult updateImportantPost(@RequestParam Map<String, Object> params) {
        AjaxResult ajaxResult = new AjaxResult();
        if (params.get("infoItems") == null || params.get("infoItems") == ""){
        	return AjaxResult.error("缺少参数infoItems【对应实体类的json格式字符串】。");
        }
        try {
        	ajaxResult= mailContentService.updateImportant(params);
        }catch (Exception e) {
            ajaxResult = AjaxResult.error(this.getExceptionMessage(e));
        }
        return ajaxResult;
    }

    /**
     * 修改保留邮件标记
     * @param infoItems 必要参数：邮件主表对应实体类的json格式字符串（包含：guid，perpetual 保留邮件，mailType 邮件状态（已收件、已发送、草稿、撤销））
     * @return AjaxResult
     * @author DH-Xxj
     */
    @PostMapping("/perpetualpost")
    @ResponseBody
    @RepeatSubmit
    public AjaxResult updatePerpetualPost(@RequestParam Map<String, Object> params) {
        AjaxResult ajaxResult = new AjaxResult();
        if (params.get("infoItems") == null || params.get("infoItems") == ""){
        	return AjaxResult.error("缺少参数infoItems【对应实体类的json格式字符串】。");
        }
        try {
        	ajaxResult= mailContentService.updatePerpetual(params);
        }catch (Exception e) {
            ajaxResult = AjaxResult.error(this.getExceptionMessage(e));
        }
        return ajaxResult;
    }

    /**
     * 获取邮件系统地址簿树
     * @param params
     * @return List
     * @throws Exception
     * @author DH-Xxj
     */
    @RequestMapping("/listtreejson")
    @ResponseBody
    public Object mailAddressBookTreeJson(@RequestParam Map<String, Object> params) {
        List<TreeDataModel> treeDataModelList = new ArrayList<TreeDataModel>();
        try{
            treeDataModelList = mailContentService.queryMailAddressBookTree(params);
            treeDataModelList = treeDataUtil.dealTreeDataModel(treeDataModelList,treeDataModelList.get(0).getMaxlevels());
        }catch(Exception e){
            return treeDataModelList;
        }
        return treeDataModelList;
    }

    /**
     * 新增邮件系统地址簿信息
     * @param infoItems 必要参数：邮件系统地址簿对应实体类的json格式字符串（包含：pGuid【上级Guid，顶级分组默认"root"】,title【组名、公司名称、部门名称、用户名称】,vtype【取值：menu,company,dept,user】,orgid【公司编码、部门编码、用户编码】）
     * @return
     * @author DH-Xxj
     */
    @PostMapping("/addbookpost")
    @ResponseBody
    @RepeatSubmit
    public AjaxResult insertMailAddressBookPost(@RequestParam Map<String, Object> params) {
        AjaxResult ajaxResult = new AjaxResult();
        if (params.get("infoItems") == null || params.get("infoItems") == ""){
        	return AjaxResult.error("缺少参数infoItems【对应实体类的json格式字符串】。");
        }
        try {
        	ajaxResult= mailContentService.insertMailAddressBook(params);
        }catch (Exception e) {
            ajaxResult = AjaxResult.error(this.getExceptionMessage(e));
        }
        return ajaxResult;
    }

    /**
     * 修改邮件系统地址簿分组名称
     * @param guid
     * @param title 名称
     * @return
     * @author DH-Xxj
     */
    @PostMapping("/editbookpost")
    @ResponseBody
    @RepeatSubmit
    public AjaxResult updateMailAddressBookForTitlePost(@RequestParam Map<String, Object> params) {
        AjaxResult ajaxResult = new AjaxResult();
        if (params.get("guid") == null || params.get("guid") == ""){
        	return AjaxResult.error("缺少参数guid【行唯一值】。");
        }
        if (params.get("title") == null || params.get("title") == ""){
        	return AjaxResult.error("缺少参数title【修改后的名称】。");
        }
        try {
        	ajaxResult= mailContentService.updateMailAddressBookForTitle(params);
        }catch (Exception e) {
            ajaxResult = AjaxResult.error(this.getExceptionMessage(e));
        }
        return ajaxResult;
    }

    /**
     * 通过Guid删除邮件系统地址簿信息
     * @param guid
     * @return
     * @author DH-Xxj
     */
    @PostMapping("/deletebookpost")
    @ResponseBody
    @RepeatSubmit
    public AjaxResult deleteMailAddressBookPost(@RequestParam Map<String, Object> params) {
        AjaxResult ajaxResult = new AjaxResult();
        if (params.get("guid") == null || params.get("guid") == ""){
        	return AjaxResult.error("缺少参数guid【行唯一值】。");
        }
        try {
        	ajaxResult= mailContentService.deleteMailAddressBook(params);
        }catch (Exception e) {
            ajaxResult = AjaxResult.error(this.getExceptionMessage(e));
        }
        return ajaxResult;
    }
    
}
